package com.example.mobie2032021606170hsy0617homework;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;



import java.util.List;

public class StaffRVAdapter extends RecyclerView.Adapter<StaffRVAdapter.ViewHolder>{
    private List<Staff> list;
    public  StaffRVAdapter(List<Staff>list){
        this.list = list;
    }
    static  class  ViewHolder extends RecyclerView.ViewHolder {
        TextView tvName, tvSkill, tvMoney;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvName = itemView.findViewById(R.id.tv_item_name);
            tvSkill = itemView.findViewById(R.id.tv_item_skill);
            tvMoney = itemView.findViewById(R.id.tv_item_money);
        }
    }
    @NonNull

    @Override
    public ViewHolder onCreateViewHolder(@NonNull  ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_main_add,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull  StaffRVAdapter.ViewHolder holder, int position) {
        Staff staff = list.get(position);
        holder.tvName.setText(""+staff.getName());
        holder.tvSkill.setText(""+staff.getSkill());
        holder.tvMoney.setText(""+staff.getMoney());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
